package algorithm.leetcode;

/**
 * @author: zhouj-j
 * @since: 2018/7/17
 */
public class __027_remove_elements {
    public int removeElement(int[] nums, int val) {
        int i = -1, j = 0;
        while (j < nums.length) {
            if (nums[j] != val) {
                nums[++i] = nums[j];
            }
            j++;
        }
        return i + 1;
    }

    public static void main(String[] args) {
        new __027_remove_elements().removeElement(new int[]{3, 2, 2, 3}, 3);
    }
}
